# valac.m4 - Check valac maximum version on the host system. -*-Autoconf-*-
# 
# This file is part of chimaira-server.
# For copyright information, see AUTHORS.
#
# server-server is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# chimaira-server is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with chimaira-server.  If not, see <http://www.gnu.org/licenses/>.

# Check whether the Vala compiler exists in `PATH'. If it is found, the
# variable VALAC is set. Optionally a maximum release number of the
# compiler can be requested.
#
# AM_PROG_VALAC_MAX([MAXIMUM-VERSION])
# --------------------------------
AC_DEFUN([AM_PROG_VALAC_MAX],
[
dnl enable if AM_PROG_VALAC was not invoked before
dnl AC_PATH_PROG([VALAC], [valac], [])
 AS_IF([test -z "$VALAC"],
   [AC_MSG_WARN([No Vala compiler found.  You will not be able to compile .vala source files.])],
   [AS_IF([test -n "$1"],
      [AC_MSG_CHECKING([$VALAC is lower than version $1])
       am__vala_version=`$VALAC --version | sed 's/Vala  *//'`
       AS_VERSION_COMPARE(["$am__vala_version"], [$1],
         [AC_MSG_RESULT([yes])],
         [AC_MSG_RESULT([no])
          AC_MSG_ERROR([Vala $am__vala_version too new.
A lower version than $1 is required.])],
         [AC_MSG_RESULT([no])
          AC_MSG_ERROR([Vala $am__vala_version too new.
A lower version than $1 is required.])])])])
])

# Check whether the Vala compiler exists in `PATH'. If it is found, the
# variable VALAC is set. Optionally a maximum release number of the
# compiler can be requested.
#
# AM_PROG_CHECK_VALAC_VERSION([VERSION_TO_COMPARE])
# --------------------------------
AC_DEFUN([AM_PROG_CHECK_VALAC_VERSION],
[
dnl enable if AM_PROG_VALAC was not invoked before
dnl AC_PATH_PROG([VALAC], [valac], [])
 AS_IF([test -z "$VALAC"],
   [AC_MSG_WARN([No Vala compiler found.  You will not be able to compile .vala source files.])],
   [AS_IF([test -n "$1"],
      [AC_MSG_CHECKING([$VALAC version found])
       am__vala_version=`$VALAC --version | sed 's/Vala  *//'`
      AC_MSG_RESULT([$am__vala_version])
       AS_VERSION_COMPARE(["$am__vala_version"], [$1],
          VALAC_VERSION_FLAG="-D VALA_MINOR_0_16",
          VALAC_VERSION_FLAG=,
          VALAC_VERSION_FLAG=)])])
])
